﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace TestThread
    {
    class ThreadAdd
        {

        /*---------------------------------------------*\
        |*                 Attributs                   *|
        \*---------------------------------------------*/	
        //input
        private double[] m_tab1;
        private double[] m_tab2;
        private int m_step;
        private int m_begin;

        //output
        private double[] m_tabResult;

        /*---------------------------------------------*\
        |*                Constructeur                 *|
        \*---------------------------------------------*/
        public ThreadAdd(double[] tab1, double[] tab2, double[] tabResult, int step, int begin)
            {
            m_tab1 = tab1;
            m_tab2 = tab2;
            m_tabResult = tabResult;
            m_step = step;
            m_begin = begin;
            }

        /*---------------------------------------------*\
        |*               Methodes public               *|
        \*---------------------------------------------*/
        public void add()
            {
            System.Console.WriteLine("Current thread = "+Thread.CurrentThread.ManagedThreadId);
            for (int i = m_begin; i < m_tab1.Length; i += m_step)
                {
                m_tabResult[i] = m_tab1[i] + m_tab2[i];
                }
            }	
        }
    }
